package com.spring.demo.untils.dto;

import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author xuweizhi
 * @since 2023/07/06 15:30
 */
@NoArgsConstructor
@Data
public class OpenRes {
    @SerializedName("logId")
    private String logId;
    @SerializedName("routeId")
    private Long routeId;
    @SerializedName("name")
    private String name;
    @SerializedName("type")
    private String type;
    @SerializedName("uri")
    private String uri;
    @SerializedName("appName")
    private String appName;
    @SerializedName("subAppName")
    private String subAppName;
    @SerializedName("status")
    private Integer status;
    @SerializedName("tid")
    private String tid;
    @SerializedName("startDateTime")
    private String startDateTime;
    @SerializedName("endDateTime")
    private String endDateTime;
    @SerializedName("cost")
    private String cost;
    @SerializedName("originRequest")
    private OriginRequestDTO originRequest;
    @SerializedName("originResponse")
    private OriginResponseDTO originResponse;
    @SerializedName("exception")
    private Object exception;


    @NoArgsConstructor
    @Data
    public static class OriginRequestDTO {

        @SerializedName("method")
        private String method;

        @SerializedName("url")
        private String url;

        @SerializedName("header")
        private HeaderDTO header;

        @SerializedName("body")
        private String body;

        @NoArgsConstructor
        @Data
        public static class HeaderDTO {
            @SerializedName("App-Key")
            private String appKey;
            @SerializedName("Org-Id")
            private String orgId;
            @SerializedName("X-Forwarded-Prefix")
            private String xForwardedPrefix;
            @SerializedName("Accept")
            private String accept;
            @SerializedName("Connection")
            private String connection;
            @SerializedName("User-Agent")
            private String userAgent;
            @SerializedName("X-Forwarded-Host")
            private String xForwardedHost;
            @SerializedName("X-Forwarded-Proto")
            private String xForwardedProto;
            @SerializedName("Host")
            private String host;
            @SerializedName("Accept-Encoding")
            private String acceptEncoding;
            @SerializedName("X-Forwarded-Port")
            private String xForwardedPort;
            @SerializedName("Campus-Id")
            private String campusId;
            @SerializedName("X-Forwarded-For")
            private String xForwardedFor;
            @SerializedName("Postman-Token")
            private String postmanToken;
            @SerializedName("Content-Length")
            private String contentLength;
            @SerializedName("X-Real-IP")
            private String xRealIP;
            @SerializedName("X-Forwarded-Server")
            private String xForwardedServer;
            @SerializedName("Content-Type")
            private String contentType;

        }
    }

    @NoArgsConstructor
    @Data
    public static class OriginResponseDTO {
        @SerializedName("status")
        private String status;
        @SerializedName("header")
        private HeaderDTO header;
        @SerializedName("body")
        private String body;

        public static OriginResponseDTO objectFromData(String str) {

            return new Gson().fromJson(str, OriginResponseDTO.class);
        }

        @NoArgsConstructor
        @Data
        public static class HeaderDTO {
            @SerializedName("App-Key")
            private String appKey;
            @SerializedName("Org-Id")
            private String orgId;
            @SerializedName("X-Forwarded-Prefix")
            private String xForwardedPrefix;
            @SerializedName("Accept")
            private String accept;
            @SerializedName("Connection")
            private String connection;
            @SerializedName("User-Agent")
            private String userAgent;
            @SerializedName("X-Forwarded-Host")
            private String xForwardedHost;
            @SerializedName("X-Forwarded-Proto")
            private String xForwardedProto;
            @SerializedName("Host")
            private String host;
            @SerializedName("Accept-Encoding")
            private String acceptEncoding;
            @SerializedName("X-Forwarded-Port")
            private String xForwardedPort;
            @SerializedName("tid")
            private String tid;
            @SerializedName("Campus-Id")
            private String campusId;
            @SerializedName("X-Forwarded-For")
            private String xForwardedFor;
            @SerializedName("Postman-Token")
            private String postmanToken;
            @SerializedName("Content-Length")
            private String contentLength;
            @SerializedName("X-Real-IP")
            private String xRealIP;
            @SerializedName("X-Forwarded-Server")
            private String xForwardedServer;
            @SerializedName("Content-Type")
            private String contentType;

        }
    }
}
